from django.conf.urls import patterns, include, url
from django.contrib.auth.models import User, Group
from rest_framework import viewsets, routers
from django.contrib import admin
from module import views as module_views
from api.views import api_view, api_doc
from store import views as store_views
from api import router
import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

api_router = router.register()

admin.autodiscover()

urlpatterns = patterns('',
    #url(r'^', include(api_router.urls)),
    (r'^pages/', include('django.contrib.flatpages.urls')),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^flagship/', include('flagship.urls')),
    url(r'^store/', include('store.urls')),
    url(r'^sdk/', include('sdk.urls')),
    url(r'^module/', include('module.urls')),
    url(r'^common/', include('jfpal.urls')),
    url(r'^wechat/', include('wechat.urls')),
    url(r'^feedback/', include('feedback.urls')),
    url(r'^customer/', include('customer.urls')),
    url('^faq/', include('faq.urls')),
    url(r'^media/(?P<path>.*)$','django.views.static.serve',{'document_root':settings.STATIC_PATH}),
    
    (r'^ckeditor/', include('ckeditor.urls')),
    
#     (r'^media/(?P<path>.*)$', 'django.views.static.serve',
#         {'document_root': settings.MEDIA_ROOT}),
#     (r'^admin_media/(?P<path>.*)$', 'django.views.static.serve',
#         {'document_root': settings.MEDIA_ROOT}),
) 

if settings.DEBUG:
    urlpatterns += patterns('',
        url(r'^api/doc', api_doc, name="api"),
    )

urlpatterns += patterns('',
        url(r'^api', api_view, name="api"),
)

#+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) \
#  + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += staticfiles_urlpatterns()



urlpatterns += patterns('',
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': settings.MEDIA_ROOT,
        }),
        url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': settings.STATIC_ROOT,
        }))


